package com.zjapl.web.action;



import com.opensymphony.xwork2.ActionSupport;
import com.zjapl.web.action.vo.Employee;
import com.zjapl.web.service.LoginService;
import com.zjapl.web.service.impl.LoginServiceImpl;
import com.zjapl.web.util.aes.AES;
import com.zjapl.web.util.mail.MailSenderInfo;
import com.zjapl.web.util.mail.SimpleMailSender;
import com.zjapl.web.util.random.RandomString;


/** 
 * @author 作者:方武斌    E-mail: fangwb@zjapl.com
 * @version 创建时间：2013-1-11 上午10:15:29 
 * 类说明 
 */
public class ResetPasswordAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
    private LoginService resetPassWord=new LoginServiceImpl();
	private Employee empSet=new Employee();
	private String email;
	    
/**  
	 * 获取empSet  
	 * @return empSet   
	 */
	public Employee getEmpSet() {
		return empSet;
	}


	/**  
	 * 设置empSet  
	 * @param empSet empSet  
	 */
	public void setEmpSet(Employee empSet) {
		this.empSet = empSet;
	}


/**  
	 * 获取email  
	 * @return email   
	 */
	public String getEmail() {
		return email;
	}


	/**  
	 * 设置email  
	 * @param email email  
	 */
public void setEmail(String email) {
		this.email = email;
	}


public String execute() throws Exception {
	String passwordtmp=String.valueOf(RandomString.NextInt(100000,999999));
    empSet.setEmail(email);
    empSet.setPassword(passwordtmp);
    
	MailSenderInfo mailInfo = new MailSenderInfo();   
    mailInfo.setMailServerHost("smtp.163.com");   
    mailInfo.setMailServerPort("25");   
    mailInfo.setValidate(true);   
    mailInfo.setUserName("zjapl_log@163.com");   
    mailInfo.setPassword("zjapl123456");//您的邮箱密码   
    mailInfo.setFromAddress("zjapl_log@163.com");   
    mailInfo.setToAddress(email);   
    mailInfo.setSubject("密码重置");   
    mailInfo.setContent("您的密码已被重置为"+passwordtmp+".<br/>请及时修改密码！");   
       //这个类主要来发送邮件  
    SimpleMailSender sms = new SimpleMailSender();  
    sms.sendHtmlMail(mailInfo);//发送html格式  
  
	String Key="http://www.zjapl.com";
	String encryptResult=AES.encrypttoStr(passwordtmp, Key);
		empSet.setPassword(encryptResult);
    resetPassWord.resetPassWord(empSet);
    return SUCCESS;
				   
}

}
